<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<body>
    <div1 class="register">
        <input type="password" class="ipt" style="float: left;">
    </div1>
    <div2>
        <p class="message" style="float: left;margin-top: 0px;margin-left: 20px;" id="a">请输入6~16位密码</p>
    </div2>
    <script type="text/javascript">
        var ipt = document.querySelector('.ipt');
        var message = document.querySelector('.message');
        var p = document.getElementById("a");
        ipt.onblur = function() {
            if (this.value.length < 6 || this.value.length > 16) {
                message.className = 'message wrong';
                message.innerHTML = '您输入的位数不对要求6~16位';
                p.style.color = "red";
            } else {
                message.className = 'message right';
                message.innerHTML = '您输入的正确';
                p.style.color = "green";
            }
        }
    </script>

</body>

</html>